package com.yk.data;


import com.yk.enums.ResultEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.experimental.Accessors;


@Data
@Accessors(chain = true)
@AllArgsConstructor
public class Result<T> {
    private Integer code;
    private String message;
    private T data;
    public static  Result fallback(){
        Result result = new Result(ResultEnum.TOO_MANY_REQUEST.getCode(),ResultEnum.TOO_MANY_REQUEST.getMessage());
        return result;
    }
    public static Result RESPOSE(ResultEnum resultEnum){
        Result result = new Result(resultEnum.getCode(),resultEnum.getMessage());
        return result;
    }
    public static Result FAIL(){
        Result result = new Result(ResultEnum.ERROR.getCode(),ResultEnum.ERROR.getMessage());
        return result;
    }
    public static Result OK() {
        Result result = new Result(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMessage());
        return result;
    }

    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Result() {
    }
}
